#include <graphics.h>
#include <conio.h>
#include <time.h>
#include "EasyXPng.h"  // 用于显示带透明通道的png图片
#include<windows.h>
#include<mmsystem.h>
#include<math.h>
#include <stdio.h>
// 引用 Windows Multimedia API
#pragma comment(lib,"Winmm.lib")

#define WIDTH 1024	//画面宽度
#define HEIGHT 576	//画面高度
#define g 7.1 //模拟重力加速度
#define g2 1.5

IMAGE im_flash1,im_flash2,im_flash3,im_arrow,im_chair,im_support,im_sweet,im_barry,im_star,im_bubble;
IMAGE im_greenhat,im_greenhat1,im_greenhat2,im_redhat,im_redhat1,im_bingling;
IMAGE im_openmouth,im_frog,im_sad; //定义青蛙
IMAGE im_bk,im_bk2,im_bk3,im_bk4,im_success;	//定义背景对象
IMAGE im_rope,im_rope1,im_rope_13,im_rope_23;	//定义绳子图像
IMAGE im_tip1,im_tip2,im_tip2_1;//定义提示语
IMAGE im_rope2_[9],im_rope3_[9];

int isCutrope = 0;//绳子状态记录
int isSweet = 0;//糖果状态记录
int gameStatus = 0; // 游戏状态，0为初始菜单界面，1为正常游戏
int Mouse;//鼠标标志变量
MOUSEMSG m;//鼠标结构体
int length = 25;  //绳子长度

void startup();
void showlevel();

void PlayMusicOnce(TCHAR fileName[80]) // 播放一次音乐函数
{
	TCHAR cmdString1[50];
	_stprintf(cmdString1, _T("open %s alias tmpmusic"), fileName);	// 生成命令字符串
	mciSendString(_T("close tmpmusic"), NULL, 0, NULL); // 先把前面一次的音乐关闭
	mciSendString(cmdString1, NULL, 0, NULL);			// 打开音乐
	mciSendString(_T("play tmpmusic"), NULL, 0, NULL); // 仅播放一次
}

void startMenu()
{
	putimage(0,0,&im_bk2);		//显示背景
	setbkmode(TRANSPARENT);
	settextcolor(WHITE);
	settextstyle(60,0, _T("Arial Rounded MT Bold"));
	outtextxy(WIDTH*0.165, HEIGHT*0.82,_T("1   Play"));
	outtextxy(2.6*WIDTH/4, HEIGHT*0.82, _T("2   Quit"));
	FlushBatchDraw();
	Sleep(2);

	char input;
	if(kbhit())  // 判断是否有输入
	{
		input = getch();  // 根据用户的不同输入来移动，不必输入回车
		if (input == '1') 
			gameStatus = 1;
		else if (input == '2')
		{
			gameStatus = 2;
			exit(0);
		}
	}
}

class Sweet  //糖果
{
public:
	float i;	
	int judge;
	float sweet_x1,sweet_y1,sweet_x2,sweet_y2; //记录糖果坐标
	float vx,vy;	//记录糖果各方向的速度
	int temp;

	void initialize1()	//第一关初始化
	{
		sweet_x1 = WIDTH/2+4;
		sweet_y1 = HEIGHT/8+220;
		i = 0;
	}

	void initialize2_1()	//第二关第一次初始化 圆周前
	{
		sweet_x2 = 2.8*WIDTH/9-87;
		sweet_y2 = HEIGHT/8+186;
		vx = 0;
		vy = 0;
		judge = 0;
		temp = 140;
	}

	void initialize2_2()	//第二关第二次初始化 下方的绿色帽子处
	{
		PlayMusicOnce(_T("music.mp3"));  //帽子音效
		sweet_x2 = 2.8*WIDTH/5+13;
		sweet_y2 = 2*HEIGHT/3+40;
		vx = 0;
		vy = 10;
	}

	void initialize2_3()		//第二关第三次初始化 青蛙上方的绿色帽子处
	{
		PlayMusicOnce(_T("music.mp3"));  //帽子音效
		sweet_x2 = 3.5*WIDTH/5+110;
		sweet_y2 = HEIGHT/7+50;
		vx = 0;
		vy = 0;
	}


	void initialize2_4()	//第二关第四次初始化 左边的红色帽子
	{
		PlayMusicOnce(_T("music.mp3"));  //帽子音效
		sweet_x2 = WIDTH/15 + 70;
		sweet_y2 = HEIGHT/3 + 75;
		vx = 8;
		vy = 10;
	}

	void initialize2_5()	// 第二关第五次初始化 上方红色帽子处
	{
		PlayMusicOnce(_T("music.mp3"));  //帽子音效
		sweet_x2 = 2.8*WIDTH/5+13;
		sweet_y2 = HEIGHT/7+40;
		vy = 0;
		vx = 0;
	}

	void updatesweet1()		// 第一关更新糖果坐标
	{	
		sweet_y1 = sweet_y1 + i;
		i = i + g;
		Sleep(10);		
		if(sweet_y1 > HEIGHT/8+380)
		{
			isCutrope = 2;
			Sleep(500);		 //第一关完成 切换 换关卡页面
		}

	}
	//第二关糖果的运动更新
	void updatesweet2_1()		//糖果向右运动	
	{
		sweet_x2 = sweet_x2 + vx;
		sweet_y2 = sweet_y2 + vy;
		vx = vx + 3.712;
		vy = vy + 0.75;
		Sleep(temp);
		temp = temp - 20;
		if(sweet_x2 > 2.72*WIDTH/9+2)
		{
			isCutrope = 6;
			PlayMusicOnce(_T("music.mp3"));  //帽子音效
			initialize2_2();
			Sleep(20);
		}
	}
	void updatesweet2_2()		//糖果向左运动
	{
		sweet_x2 = sweet_x2 + vx;
		sweet_y2 = sweet_y2 + vy;
		vx = vx - 3.712;
		vy = vy + 0.75;
		Sleep(temp);
		temp = temp - 20;
		if(sweet_x2 < WIDTH/9+20)
		{
			isCutrope = 8;
			PlayMusicOnce(_T("music.mp3"));  //帽子音效
			initialize2_5();
			Sleep(20);
		}
	}

	void updatesweet2_3()		//糖果从绿色帽子弹出
	{
		if(isSweet == 0||isSweet == 1)
		{
			sweet_y2 = sweet_y2 - g2*vy;
			vy = vy - 0.5;
			Sleep(15);
		}

		if(isSweet == 2 || isSweet == 3)
		{
			sweet_y2 = sweet_y2 - 1;
		}

		if(isSweet == 4 && judge == 4)
		{
			sweet_y2 = sweet_y2 + g2 * vy;
			vy = vy + 0.5;
			if(sweet_y2 > 2*HEIGHT/3+37)
			{
				isSweet = 5;
				judge = 5;
				initialize2_3();
			}
		}
		if(isSweet == 5 && judge == 5)
		{
			sweet_y2 = sweet_y2 + g2 * vy;
			vy = vy + 0.5;
			Sleep(15);
			if(sweet_y2 > 2*HEIGHT/3 + 60)
			{
					Sleep(500);		//游戏成功
					isSweet = 8;
			}
		}
		if(isSweet == 6)
		{
			sweet_x2 = sweet_x2 + vx;
			sweet_y2 = sweet_y2 - 5; 
			vx = vx - 0.5;
			if(vx <= 0)
				vx = 0;
			if(sweet_y2 < -80)		//糖果出画
			{
				isSweet = 7;
				judge = 7;
				Sleep(500);
			}
		}

		//糖果状态判断
		/*---割左绳 isSweet意义解释(judge同理)：
			1--碰到下面星星
			2-- 碰到中间星星
			3-- 碰到上面星星
			4-- 点击气泡 
			5-- 在最右边自由落体完成游戏
			6-- 未点击气泡 从左侧红帽子飘出
		*/
		if(sweet_y2 < 2*HEIGHT/3-25 && judge == 0)  //下面星星
		{
			isSweet = 1;
			judge = 1;
		//	Sleep(50);
		}
		if(sweet_y2 < 2*HEIGHT/3-100 && judge == 1)	//中间星星
		{
			isSweet = 2;
			judge = 2;
			//putimagePng(WIDTH/2+87,2*HEIGHT/3-100,&im_bingling); //中
		//	Sleep(50);
		}
		if(sweet_y2 < 2*HEIGHT/3-175)	//上面星星
		{
			if(judge == 2)
			{
				isSweet = 3;
				judge = 3;
			}
			if(sweet_y2 < HEIGHT/7+40 && judge == 3)
			{
				isSweet = 6;
				judge = 6;
				initialize2_4();
			}
		}

	}

	void touch(float x,float y)
	{
		if(sweet_x2 < x && sweet_y2 < y && sweet_x2 + 67 > x   && sweet_y2 + 67 > y)	//如果点击泡泡
		{
			PlayMusicOnce(_T("bubble.mp3"));  //气泡音效
			isSweet = 4;
			judge = 4;
			vy = 10;
		}
	}

	void updatesweet2_4()	//糖果从红帽子向下
	{
		if(isSweet == 0||isSweet == 1)
		{
			sweet_y2 = sweet_y2 + g2*vy;
			vy = vy + 0.5;
			Sleep(15);
		}
		if(isSweet == 2)
		{
			sweet_y2 = sweet_y2 - 1;
		}
		if(sweet_y2 < HEIGHT/7+40 && judge == 2)
			{
				isSweet = 6;
				judge = 6;
				initialize2_4();
			}
		if(isSweet == 5 && judge == 5)
		{
			sweet_y2 = sweet_y2 + g2 * vy;
			vy = vy + 0.5;
			Sleep(15);
			if(sweet_y2 > 2*HEIGHT/3 + 60)
			{
					Sleep(500);		//游戏成功
					isSweet = 8;
			}
		}
		if(isSweet == 6)
		{
			sweet_x2 = sweet_x2 + vx;
			sweet_y2 = sweet_y2 - 5; 
			vx = vx - 0.5;
			if(vx <= 0)
				vx = 0;
			if(sweet_y2 < -80)		//糖果出画
			{
				isSweet = 7;
				judge = 7;
				Sleep(500);
			}
		}

		//糖果状态判断
		/*---割左绳 isSweet意义解释(judge同理)：
			0 -- 向下运动
			1-- 碰到上面星星
			2-- 碰到中间星星
			3-- 
			4-- 点击气泡 
			5-- 在最右边自由落体完成游戏
			6-- 未点击气泡 从左侧红帽子飘出
		*/
		if(sweet_y2 > 2*HEIGHT/3-175 && judge == 0)		//碰到上面的星星
		{
			isSweet = 1;
			judge =1;
		}

		if(sweet_y2 > 2*HEIGHT/3-100 && judge == 1)  //向下逐渐接触泡泡
		{
			isSweet = 2;
			judge = 2;
		}
		
		if(isSweet == 4 && judge == 4)
		{
			sweet_y2 = sweet_y2 + g2 * vy;
			vy = vy + 0.5;
			if(sweet_y2 > 2*HEIGHT/3+37)
			{
				isSweet = 5;
				judge = 5;
				initialize2_3();
			
			}
		}
	}
};
Sweet sweet;

void startup()		//初始化函数
{
	int j ;
	mciSendString(_T("open backgroundmusic.mp3 alias bkmusic"), NULL, 0, NULL);//打开背景音乐
	mciSendString(_T("play bkmusic repeat"), NULL, 0, NULL);  // 循环播放

	initgraph(WIDTH,HEIGHT);
	// 获取窗口句柄
	HWND hwnd = GetHWnd();
	// 设置窗口标题文字
	SetWindowText(hwnd, _T("割绳子"));

	loadimage(&im_bk2,_T("bk2.jpg"),WIDTH,HEIGHT);	 // 导入初始界面背景图片
	loadimage(&im_bk,_T("background.png"));			// 导入level1背景图片
	loadimage(&im_bk3,_T("bk3.jpg"));		 // 导入level2背景图片
	loadimage(&im_bk4,_T("bk4.jpg"));		// 导入level3背景图片
	loadimage(&im_success,_T("success.png"),WIDTH,HEIGHT);  //完成第一关
	///loadimage(&im_arrow,_T("arrow.png"));		// 导入箭头图片
	loadimage(&im_barry,_T("barry.png"));	 // 导入障碍图片
	// 导入小青蛙图片
	loadimage(&im_frog,_T("frog.png"));		 
	loadimage(&im_openmouth,_T("openmouth.png"));
	loadimage(&im_sad,_T("sad.png"));
	loadimage(&im_bingling,_T("bingling.png"));	 
	loadimage(&im_chair,_T("chair.png"));		 // 导入椅子图片
	loadimage(&im_star,_T("star.png"));	 // 导入星星图片
	loadimage(&im_bubble,_T("bubble.png"));	 // 导入泡泡图片
	loadimage(&im_support,_T("support.png"));	 // 导入支撑点图片
	loadimage(&im_sweet,_T("sweet.png"));		//导入糖果照片
	//导入刀光
	loadimage(&im_flash1,_T("flash1.png"));	
	loadimage(&im_flash2,_T("flash2.png"));
	loadimage(&im_flash3,_T("flash3.png"));
	// 导入绳子图片
	loadimage(&im_rope,_T("rope.png"));	
	loadimage(&im_rope1,_T("rope1.png"));
	loadimage(&im_rope_13,_T("rope_13.png"));	
	loadimage(&im_rope_23,_T("rope_23.png"));
	//图片数组
	loadimage(&im_rope2_[0],_T("rope2_0.png"));
	loadimage(&im_rope2_[1],_T("rope2_1.png"));
	loadimage(&im_rope2_[2],_T("rope2_2.png"));
	loadimage(&im_rope2_[3],_T("rope2_3.png"));
	loadimage(&im_rope2_[4],_T("rope2_4.png"));
	loadimage(&im_rope2_[5],_T("rope2_5.png"));
	loadimage(&im_rope2_[6],_T("rope2_6.png"));
	loadimage(&im_rope2_[7],_T("rope2_7.png"));
	loadimage(&im_rope2_[8],_T("rope2_8.png"));
	loadimage(&im_rope3_[0],_T("rope3_0.png"));
	loadimage(&im_rope3_[1],_T("rope3_1.png"));
	loadimage(&im_rope3_[2],_T("rope3_2.png"));
	loadimage(&im_rope3_[3],_T("rope3_3.png"));
	loadimage(&im_rope3_[4],_T("rope3_4.png"));
	loadimage(&im_rope3_[5],_T("rope3_5.png"));
	loadimage(&im_rope3_[6],_T("rope3_6.png"));
	loadimage(&im_rope3_[7],_T("rope3_7.png"));
	loadimage(&im_rope3_[8],_T("rope3_8.png"));

	// 导入帽子图片
	loadimage(&im_greenhat,_T("greenhat.png"));	 
	loadimage(&im_greenhat1,_T("greenhat1.png"));
	loadimage(&im_greenhat2,_T("greenhat2.png"));
	loadimage(&im_redhat,_T("redhat.png"));	
	loadimage(&im_redhat1,_T("redhat1.png"));	
	//导入提示语
	loadimage(&im_tip1,_T("tip1.png"));
	loadimage(&im_tip2,_T("tip2.png"));
	loadimage(&im_tip2_1,_T("tip2(1).png"));

	initgraph(WIDTH,HEIGHT); // 新开一个画面
	BeginBatchDraw(); // 开始批量绘制

	while (gameStatus==0)
		startMenu();	// 初始菜单界面
	//各关卡糖果运动数据初始化
	sweet.initialize1();
	sweet.initialize2_1();
}

class Scene
{
public:
	float array[9];		//此数组用于解决右边绳子圆周运动圆心在图片左边的问题
	int temp1;			//辅助值
	int temp2;
	void start_1()		//第一关起始画面
	{	
		//显示绳子
		putimagePng(WIDTH/2+27,HEIGHT/8+20,&im_rope);
		putimagePng(WIDTH/2+27,HEIGHT/8+20+length,&im_rope);
		putimagePng(WIDTH/2+27,HEIGHT/8+20+2*length,&im_rope);
		putimagePng(WIDTH/2+27,HEIGHT/8+20+3*length,&im_rope);
		putimagePng(WIDTH/2+27,HEIGHT/8+20+4*length,&im_rope);
		putimagePng(WIDTH/2+27,HEIGHT/8+20+5*length,&im_rope);
		putimagePng(WIDTH/2+27,HEIGHT/8+20+6*length,&im_rope);
		putimagePng(WIDTH/2+27,HEIGHT/8+20+7*length,&im_rope);

		putimagePng(WIDTH/2-44,3*HEIGHT/4,&im_chair); //显示椅子
		putimagePng(WIDTH/2-5,2*HEIGHT/3+37,&im_frog); //显示小青蛙
		putimagePng(WIDTH/2+4, HEIGHT/8+220, &im_sweet); // 显示糖果
		putimagePng(WIDTH/2+4,HEIGHT/8,&im_support); //显示支撑点
		putimagePng(0,2*HEIGHT/3,&im_tip2); //显示提示语
	}

	void start_2()			//第二关起始画面
	{
		putimage(0,0,&im_bk3);		//显示背景3	
		putimagePng(3.8*WIDTH/5+3,3*HEIGHT/4,&im_chair); //显示椅子

		putimagePng(WIDTH/9+73,2*HEIGHT/3+50,&im_barry); //显示障碍
		putimagePng(WIDTH/9+73,2*HEIGHT/3+85,&im_barry); 

		//显示帽子
		putimagePng(1.6*WIDTH/5,HEIGHT/3+35,&im_greenhat1); //绿 向左
		putimagePng(WIDTH/15,HEIGHT/3+65,&im_redhat1);		//红 向右
		putimagePng(2.8*WIDTH/5-10,2*HEIGHT/3+37,&im_greenhat2); //绿 向上
		putimagePng(3.5*WIDTH/5+60,HEIGHT/7-20,&im_greenhat); //绿  向下
		putimagePng(WIDTH/2+50,HEIGHT/7-20,&im_redhat);		//红 向下

		//显示星星
		putimagePng(WIDTH/2+87,2*HEIGHT/3-25,&im_star); // 下
		putimagePng(WIDTH/2+87,2*HEIGHT/3-100,&im_star); //中
		putimagePng(WIDTH/2+87,2*HEIGHT/3-175,&im_star); //上

		//显示绳子
		putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23);   //左边
		putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
		putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
		putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
		putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
		putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
		putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
		putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
		putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);

		putimagePng(2.8*WIDTH/9+12,HEIGHT/8+35,&im_rope_13);	//右边
		putimagePng(2.8*WIDTH/9+3,HEIGHT/8+52,&im_rope_13);
		putimagePng(2.8*WIDTH/9-6,HEIGHT/8+68,&im_rope_13);
		putimagePng(2.8*WIDTH/9-15,HEIGHT/8+83,&im_rope_13);
		putimagePng(2.8*WIDTH/9-24,HEIGHT/8+100,&im_rope_13);
		putimagePng(2.8*WIDTH/9-33,HEIGHT/8+116,&im_rope_13);
		putimagePng(2.8*WIDTH/9-42,HEIGHT/8+132,&im_rope_13);
		putimagePng(2.8*WIDTH/9-51,HEIGHT/8+147,&im_rope_13);
		putimagePng(2.8*WIDTH/9-60,HEIGHT/8+162,&im_rope_13);
		putimagePng(2.8*WIDTH/9-63,HEIGHT/8+165,&im_rope_13);

		putimagePng(WIDTH/9+20,HEIGHT/8 ,&im_support); //显示支撑点
		putimagePng(2.8*WIDTH/9+5,HEIGHT/8 ,&im_support);
		putimagePng(4*WIDTH/5,2*HEIGHT/3 + 37,&im_frog); //显示小青蛙
		putimagePng(WIDTH/2+70,2*HEIGHT/3-115,&im_bubble); //显示泡泡
		putimagePng(2.8*WIDTH/9-87,HEIGHT/8+186, &im_sweet); // 显示糖果
		temp1 = 0;
		temp2 = 0;

	}

	void start2()		//第二关割绳子后的基础显示
	{
		putimage(0,0,&im_bk3);		//显示背景3	
		putimagePng(3.8*WIDTH/5+3,3*HEIGHT/4,&im_chair); //显示椅子

		putimagePng(WIDTH/9+73,2*HEIGHT/3+50,&im_barry); //显示障碍
		putimagePng(WIDTH/9+73,2*HEIGHT/3+85,&im_barry); 
		//显示帽子
		putimagePng(1.6*WIDTH/5,HEIGHT/3+35,&im_greenhat1); //绿 向左
		putimagePng(WIDTH/15,HEIGHT/3+65,&im_redhat1);		//红 向右
		putimagePng(2.8*WIDTH/5-10,2*HEIGHT/3+37,&im_greenhat2); //绿 向上
		putimagePng(3.5*WIDTH/5+60,HEIGHT/7-20,&im_greenhat); //绿  向下
		putimagePng(WIDTH/2+50,HEIGHT/7-20,&im_redhat);		//红 向下
		if(isSweet != 5 && isSweet != 6)
			putimagePng(4*WIDTH/5,2*HEIGHT/3 + 37,&im_frog); //显示小青蛙
		if(isSweet == 5)
			putimagePng(4*WIDTH/5,2*HEIGHT/3 + 37,&im_openmouth); //显示小青蛙张嘴
		if(isSweet == 6)
		{
			putimagePng(4*WIDTH/5,2*HEIGHT/3 + 37,&im_sad);	//难过
			PlayMusicOnce(_T("sad.mp3"));  //音效
		}

	}

	void level2_1()		//第二关第一种情况  割左边
	{
		float array[9] = {2.28,2.35,2.43,2.53,2.66,2.75,2.84,2.945,3.0};
		start2();
		putimagePng(array[temp2]*WIDTH/9,HEIGHT/8+30,&im_rope2_[temp1]);	//右边绳子的显示
		temp1++;
		temp2++;
		//显示星星
		putimagePng(WIDTH/2+87,2*HEIGHT/3-25,&im_star); // 下
		putimagePng(WIDTH/2+87,2*HEIGHT/3-100,&im_star); //中
		putimagePng(WIDTH/2+87,2*HEIGHT/3-175,&im_star); //上
		putimagePng(WIDTH/2+70,2*HEIGHT/3-115,&im_bubble); //显示泡泡
		putimagePng(WIDTH/9+20,HEIGHT/8 ,&im_support); //显示支撑点
		putimagePng(2.8*WIDTH/9+5,HEIGHT/8 ,&im_support);
		//	if(temp == 8)
		//		isCutrope == 6;
	}

	void level2_2()		//第二关第二种情况  割右边
	{
		start2();
		putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope3_[temp1]); //左边绳子的显示	
		temp1++;
		//显示星星
		putimagePng(WIDTH/2+87,2*HEIGHT/3-25,&im_star); // 下
		putimagePng(WIDTH/2+87,2*HEIGHT/3-100,&im_star); //中
		putimagePng(WIDTH/2+87,2*HEIGHT/3-175,&im_star); //上
		putimagePng(WIDTH/2+70,2*HEIGHT/3-115,&im_bubble); //显示泡泡
		putimagePng(WIDTH/9+20,HEIGHT/8 ,&im_support); //显示支撑点
		putimagePng(2.8*WIDTH/9+5,HEIGHT/8 ,&im_support);
		//	if(temp == 8)
		//	isCutrope == 7;
	}

	void level2_3()	//从绿色帽子弹出
	{
		start2();
		putimagePng(WIDTH/9+20,HEIGHT/8 ,&im_support); //显示支撑点
		putimagePng(2.8*WIDTH/9+5,HEIGHT/8 ,&im_support);
	}

	void level2_4()	//从上方落下
	{
		start2();
		putimagePng(WIDTH/9+20,HEIGHT/8 ,&im_support); //显示支撑点
		putimagePng(2.8*WIDTH/9+5,HEIGHT/8 ,&im_support);
	}

	void change_1()			//第一关完成后的选择界面
	{
		putimage(0,0,&im_success);		//显示背景
		setbkmode(TRANSPARENT);
		settextcolor(WHITE);
		settextstyle(60,0, _T("Arial Rounded MT Bold"));
		outtextxy(WIDTH*0.165, HEIGHT*0.71,_T("1   Next"));
		outtextxy(2.4*WIDTH/4, HEIGHT*0.71, _T("2   Replay"));
		putimagePng(WIDTH/8,HEIGHT/7,&im_tip1);		//显示提示语
		FlushBatchDraw();
		Sleep(2);
	}
	void success()
	{
		putimage(0,0,&im_success);		//显示背景
		setbkmode(TRANSPARENT);
		settextcolor(WHITE);
		settextstyle(60,0, _T("Arial Rounded MT Bold"));
		outtextxy(WIDTH*0.165, HEIGHT*0.71,_T("1  Replay"));
		outtextxy(2.4*WIDTH/4, HEIGHT*0.71, _T("2    Quit"));
		if(isSweet == 8)
			putimagePng(WIDTH/8,HEIGHT/7,&im_tip1);		//显示成功提示语
		else if(isSweet == 7)
			putimagePng(WIDTH/8,HEIGHT/7,&im_tip2_1);		//显示失败提示语
		FlushBatchDraw();
		Sleep(2);
	}
};
Scene scene;

void showlevel()		//	绘制关卡
{
	putimage(0,0,&im_bk2);		//显示背景2	
	putimagePng(0,0,&im_bk);		//显示背景	
	if(isCutrope == 0)
		scene.start_1();
	if(isCutrope == 1)
	{
		putimagePng(WIDTH/2-5,2*HEIGHT/3 + 37,&im_openmouth); //显示小青蛙
		sweet.updatesweet1();
		putimagePng(sweet.sweet_x1,sweet.sweet_y1, &im_sweet);	//显示糖果
		//这里游戏就成功了，准备换下一关
	}
	if(isCutrope == 2)		//第一关完成后的选择界面
		scene.change_1();	
	if(isCutrope == 3)		//开始第二关初始画面
		scene.start_2();
	if(isCutrope == 4)		//第二关割右边绳子
	{
		sweet.updatesweet2_1();
		scene.level2_1();
		putimagePng(sweet.sweet_x2,sweet.sweet_y2, &im_sweet);	
	}
	if(isCutrope == 5)		//第二关割左边绳子
	{
		sweet.updatesweet2_2();
		scene.level2_2();
		putimagePng(sweet.sweet_x2,sweet.sweet_y2, &im_sweet);	//显示糖果
	}
	if(isCutrope == 6)	//割左边绳子
	{
		sweet.updatesweet2_3();   
		scene.level2_3();
		putimagePng(sweet.sweet_x2,sweet.sweet_y2, &im_sweet);	//显示糖果
		if(isSweet == 0)
		{
			PlayMusicOnce(_T("music.mp3"));  //帽子音效
			putimagePng(WIDTH/2+87,2*HEIGHT/3-25,&im_star); // 下
			putimagePng(WIDTH/2+87,2*HEIGHT/3-100,&im_star); //中
			putimagePng(WIDTH/2+87,2*HEIGHT/3-175,&im_star); //上				
			putimagePng(WIDTH/2+70,2*HEIGHT/3-115,&im_bubble); //显示泡泡
		}
		if(isSweet == 1)
		{
			putimagePng(WIDTH/2+87,2*HEIGHT/3-100,&im_star); //中
			putimagePng(WIDTH/2+87,2*HEIGHT/3-175,&im_star); //上
			PlayMusicOnce(_T("bingling.mp3"));  //星星音效
			putimagePng(WIDTH/2+60,2*HEIGHT/3-50,&im_bingling); //下面的		
			putimagePng(WIDTH/2+70,2*HEIGHT/3-115,&im_bubble); //显示泡泡
		}
		if(isSweet == 2)
		{
			PlayMusicOnce(_T("bingling.mp3"));  //星星音效
			putimagePng(WIDTH/2+87,2*HEIGHT/3-175,&im_star); //上
			putimagePng(sweet.sweet_x2-2,sweet.sweet_y2-10,&im_bubble); //显示泡泡
		}
		if(isSweet == 3)
		{
			PlayMusicOnce(_T("bingling.mp3"));  //星星音效
			putimagePng(sweet.sweet_x2-2,sweet.sweet_y2-10,&im_bubble); //显示泡泡
		}
		if(isSweet == 4||isSweet == 5)
		{
			putimagePng(sweet.sweet_x2,sweet.sweet_y2, &im_sweet);	//显示糖果
		}
		if(isSweet == 6)
		{
			putimagePng(sweet.sweet_x2-2,sweet.sweet_y2-10,&im_bubble); //显示泡泡
		}
		if(isSweet ==7||isSweet == 8)
		{
			scene.success();		//游戏结果
		}

	}
	if(isCutrope == 8)	//割右边绳子
	{
		sweet.updatesweet2_4();
		scene.level2_4();
		putimagePng(sweet.sweet_x2,sweet.sweet_y2, &im_sweet);	//显示糖果

		if(isSweet == 0)
		{
			PlayMusicOnce(_T("music.mp3"));  //帽子音效
			putimagePng(WIDTH/2+87,2*HEIGHT/3-25,&im_star); // 下
			putimagePng(WIDTH/2+87,2*HEIGHT/3-100,&im_star); //中
			putimagePng(WIDTH/2+87,2*HEIGHT/3-175,&im_star); //上
			putimagePng(sweet.sweet_x2-2,sweet.sweet_y2-10,&im_bubble); //显示泡泡
		}
		if(isSweet == 1)
		{
			PlayMusicOnce(_T("bingling.mp3"));  //星星音效
			putimagePng(WIDTH/2+87,2*HEIGHT/3-25,&im_star); // 下
			putimagePng(WIDTH/2+87,2*HEIGHT/3-100,&im_star); //中
			putimagePng(WIDTH/2+60,2*HEIGHT/3-200,&im_bingling); //闪烁效果
			putimagePng(sweet.sweet_x2-2,sweet.sweet_y2-10,&im_bubble); //显示泡泡
		}
		if(isSweet == 2)
		{
			PlayMusicOnce(_T("bingling.mp3"));  //星星音效
			putimagePng(WIDTH/2+87,2*HEIGHT/3-25,&im_star); // 下
			putimagePng(sweet.sweet_x2-2,sweet.sweet_y2-10,&im_bubble); //显示泡泡
		}
		if(isSweet == 3)
		{
			putimagePng(WIDTH/2+87,2*HEIGHT/3-25,&im_star); // 下
			putimagePng(sweet.sweet_x2-2,sweet.sweet_y2-10,&im_bubble); //显示泡泡
		}
		if(isSweet == 4||isSweet == 5)
			putimagePng(sweet.sweet_x2,sweet.sweet_y2, &im_sweet);	//显示糖果

		if(isSweet == 6)
		{
			putimagePng(sweet.sweet_x2-2,sweet.sweet_y2-10,&im_bubble); //显示泡泡
		}
		if(isSweet ==7||isSweet == 8)
		{
			scene.success();		//游戏结果

		}
	}

	//关卡转换
	while(isCutrope == 2)
	{
		char input;
		if(kbhit())  // 判断是否有输入
		{
			input = getch();  // 根据用户的不同输入来移动，不必输入回车
			if (input == '1') 
				isCutrope = 3;				
			else if (input == '2')
			{
				sweet.initialize1();
				isCutrope = 0;
			}
		}
		FlushBatchDraw();
	}	
	while(isSweet == 7 || isSweet == 8)
	{
		char input;
		if(kbhit())  // 判断是否有输入
		{
			input = getch();  // 根据用户的不同输入来移动，不必输入回车
			if (input == '1') 
			{
				isCutrope = 3;
				sweet.initialize2_1();
				isSweet = 0;
			}

			else if (input == '2')
			{
				gameStatus = 2;
				exit(0);
			}
		}
		FlushBatchDraw();
	}	

	////putimagePng(m.x-15,m.y-10, &im_arrow); // 显示箭头
	FlushBatchDraw(); // 批量绘制
}

class Rope
{
public:
	void Cutropelevel1(float x,float y)		//第一关 当割绳子时
	{
		if(x<WIDTH/2+100 && x>WIDTH/2 && y<HEIGHT/8+220 && y>HEIGHT/8+30)
		{
			isCutrope = 1;
			showlevel();  // 绘制
			putimagePng(x-45,y-3,&im_flash1);	 //显示刀光
			PlayMusicOnce(_T("cutrope.mp3"));  //割绳子音效

			//依次对于位置判断
			if(x<WIDTH/2+100 && x>WIDTH/2 && y<=HEIGHT/8+50 && y>HEIGHT/8+30)//rope1
			{
				//显示绳子
				//putimagePng(WIDTH/2+27,HEIGHT/8+40,&im_rope1);
				putimagePng(WIDTH/2+35,HEIGHT/8+20+1*length,&im_rope1);
				putimagePng(WIDTH/2+34,HEIGHT/8+20+2*length,&im_rope);
				putimagePng(WIDTH/2+33,HEIGHT/8+20+3*length,&im_rope);
				putimagePng(WIDTH/2+32,HEIGHT/8+20+4*length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+5*length,&im_rope);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+6*length,&im_rope);
				putimagePng(WIDTH/2+29,HEIGHT/8+20+7*length,&im_rope);

			}
			if(x<WIDTH/2+100 && x>WIDTH/2 && y<=HEIGHT/8+75 && y>HEIGHT/8+50)//rope2
			{
				//显示绳子
				putimagePng(WIDTH/2+29,HEIGHT/8+40,&im_rope1);
				//putimagePng(WIDTH/2+27,HEIGHT/8+20+1*length,&im_rope);
				putimagePng(WIDTH/2+34,HEIGHT/8+20+2*length,&im_rope);
				putimagePng(WIDTH/2+33,HEIGHT/8+20+3*length,&im_rope);
				putimagePng(WIDTH/2+32,HEIGHT/8+20+4*length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+5*length,&im_rope);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+6*length,&im_rope);
				putimagePng(WIDTH/2+29,HEIGHT/8+20+7*length,&im_rope);
			}

			if(x<WIDTH/2+100 && x>WIDTH/2 && y<=HEIGHT/8+100 && y>HEIGHT/8+75)//rope3
			{
				//显示绳子
				putimagePng(WIDTH/2+29,HEIGHT/8+40,&im_rope1);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+length,&im_rope);
				//putimagePng(WIDTH/2+27,HEIGHT/8+20+2*length,&im_rope);
				putimagePng(WIDTH/2+33,HEIGHT/8+20+3*length,&im_rope);
				putimagePng(WIDTH/2+32,HEIGHT/8+20+4*length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+5*length,&im_rope);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+6*length,&im_rope);
				putimagePng(WIDTH/2+29,HEIGHT/8+20+7*length,&im_rope);
			}
			if(x<WIDTH/2+100 && x>WIDTH/2 && y<=HEIGHT/8+125 && y>HEIGHT/8+100)//rope4
			{
				//显示绳子
				putimagePng(WIDTH/2+29,HEIGHT/8+40,&im_rope1);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+2*length,&im_rope);
				//putimagePng(WIDTH/2+27,HEIGHT/8+20+3*length,&im_rope);
				putimagePng(WIDTH/2+33,HEIGHT/8+20+4*length,&im_rope);
				putimagePng(WIDTH/2+32,HEIGHT/8+20+5*length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+6*length,&im_rope);
				putimagePng(WIDTH/2+29,HEIGHT/8+20+7*length,&im_rope);
			}
			if(x<WIDTH/2+100 && x>WIDTH/2 && y<=HEIGHT/8+150 && y>HEIGHT/8+125)//rope5
			{
				//显示绳子
				putimagePng(WIDTH/2+29,HEIGHT/8+40,&im_rope1);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+1*length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+2*length,&im_rope);
				putimagePng(WIDTH/2+32,HEIGHT/8+20+3*length,&im_rope);
				//putimagePng(WIDTH/2+27,HEIGHT/8+20+4*length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+5*length,&im_rope);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+6*length,&im_rope);
				putimagePng(WIDTH/2+29,HEIGHT/8+20+7*length,&im_rope);
			}
			if(x<WIDTH/2+100 && x>WIDTH/2 && y<=HEIGHT/8+175 && y>HEIGHT/8+150)//rope6
			{
				//显示绳子
				putimagePng(WIDTH/2+29,HEIGHT/8+40,&im_rope1);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+1*length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+2*length,&im_rope);
				putimagePng(WIDTH/2+32,HEIGHT/8+20+3*length,&im_rope);
				putimagePng(WIDTH/2+33,HEIGHT/8+20+4*length,&im_rope);
				//putimagePng(WIDTH/2+27,HEIGHT/8+20+5*length,&im_rope);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+6*length,&im_rope);
				putimagePng(WIDTH/2+29,HEIGHT/8+20+7*length,&im_rope);
			}

			if(x<WIDTH/2+100 && x>WIDTH/2 && y<=HEIGHT/8+200 && y>HEIGHT/8+175)//rope7
			{
				//显示绳子
				putimagePng(WIDTH/2+29,HEIGHT/8+40,&im_rope1);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+1*length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+2*length,&im_rope);
				putimagePng(WIDTH/2+32,HEIGHT/8+20+3*length,&im_rope);
				putimagePng(WIDTH/2+33,HEIGHT/8+20+4*length,&im_rope);
				putimagePng(WIDTH/2+34,HEIGHT/8+20+5*length,&im_rope);
				//putimagePng(WIDTH/2+27,HEIGHT/8+20+6*length,&im_rope);
				putimagePng(WIDTH/2+29,HEIGHT/8+20+7*length,&im_rope);
			}
			if(x<WIDTH/2+100 && x>WIDTH/2 && y<=HEIGHT/8+220 && y>HEIGHT/8+200)//rope8
			{
				//显示绳子
				putimagePng(WIDTH/2+29,HEIGHT/8+40,&im_rope1);
				putimagePng(WIDTH/2+30,HEIGHT/8+20+1*length,&im_rope);
				putimagePng(WIDTH/2+31,HEIGHT/8+20+2*length,&im_rope);
				putimagePng(WIDTH/2+32,HEIGHT/8+20+3*length,&im_rope);
				putimagePng(WIDTH/2+33,HEIGHT/8+20+4*length,&im_rope);
				putimagePng(WIDTH/2+34,HEIGHT/8+20+5*length,&im_rope);
				putimagePng(WIDTH/2+35,HEIGHT/8+20+6*length,&im_rope);
				//putimagePng(WIDTH/2+27,HEIGHT/8+20+7*length,&im_rope);
			}
			putimagePng(WIDTH/2+4,HEIGHT/8 ,&im_support); //显示支撑点
			FlushBatchDraw();

		}	

	}

	void Cutropelevel2(float x,float y)		//第二关 当割绳子时
	{
		if(x<2.8*WIDTH/9+20 && x>WIDTH/9+20 && y<HEIGHT/8+180 && y>HEIGHT/8+30)
		{
			PlayMusicOnce(_T("cutrope.mp3"));  //割绳子音效			
		}

		if(x<WIDTH/9+140)		//割左边绳子
		{
			isCutrope = 4;
			showlevel();  // 绘制
			putimagePng(x-85,y-40,&im_flash2);	 //显示刀光

			if(x<WIDTH/9+140 && x>WIDTH/9+20 && y<HEIGHT/8+50 && y>HEIGHT/8+30)	
			{
				//putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23); 
				putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
				putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
				putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
				putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
				putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
				putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
				putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
				putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);
			}

			if(x<WIDTH/9+140 && x>WIDTH/9+20 && y<HEIGHT/8+65 && y>=HEIGHT/8+50)		
			{
				//显示绳子
				//putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23); 
				//putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
				putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
				putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
				putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
				putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
				putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
				putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
				putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);

			}

			if(x<WIDTH/9+140 && x>WIDTH/9+20 && y<HEIGHT/8+90 && y>=HEIGHT/8+65)
			{
				//显示绳子
				putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23); 
				//	putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
				//	putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
				putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
				putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
				putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
				putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
				putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
				putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);

			}

			if(x<WIDTH/9+140 && x>WIDTH/9+20 && y<HEIGHT/8+110 && y>=HEIGHT/8+90)
			{
				//显示绳子
				putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23); 
				putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
				//putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
				//putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
				putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
				putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
				putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
				putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
				putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);
			}

			if(x<WIDTH/9+140 && x>WIDTH/9+20 && y<HEIGHT/8+130&& y>=HEIGHT/8+110)
			{
				//显示绳子
				putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23);  
				putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
				putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
				//putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
				//putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
				putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
				putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
				putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
				putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);
			}
			if(x<WIDTH/9+140 && x>WIDTH/9+20 && y<HEIGHT/8+140&& y>=HEIGHT/8+130)
			{
				//显示绳子
				putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23);  
				putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
				putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
				putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
				//	putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
				//	putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
				putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
				putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
				putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);
			}
			if(x<WIDTH/9+140 && x>WIDTH/9+20 && y<HEIGHT/8+160&& y>=HEIGHT/8+140)
			{
				//显示绳子
				putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23); 
				putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
				putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
				putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
				putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
				//putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
				//putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
				putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
				putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);

			}
			if(x<WIDTH/9+140 && x>WIDTH/9+20 && y<HEIGHT/8+170&& y>=HEIGHT/8+160)
			{
				//显示绳子
				putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23);  
				putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
				putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
				putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
				putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
				putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
				//	putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
				//	putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
				putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);

			}
			if(x<WIDTH/9+140 && x>WIDTH/9+20 && y<HEIGHT/8+180&& y>=HEIGHT/8+170)
			{
				//显示绳子
				putimagePng(WIDTH/9+40,HEIGHT/8+33 ,&im_rope_23);   
				putimagePng(WIDTH/9+51,HEIGHT/8+50,&im_rope_23);
				putimagePng(WIDTH/9+64,HEIGHT/8+71,&im_rope_23);
				putimagePng(WIDTH/9+77,HEIGHT/8+92,&im_rope_23);
				putimagePng(WIDTH/9+88,HEIGHT/8+110,&im_rope_23);
				putimagePng(WIDTH/9+99,HEIGHT/8+127 ,&im_rope_23);
				putimagePng(WIDTH/9+108,HEIGHT/8+141 ,&im_rope_23);
				//	putimagePng(WIDTH/9+119,HEIGHT/8+156 ,&im_rope_23);
				//	putimagePng(WIDTH/9+129,HEIGHT/8+170 ,&im_rope_23);
			}
			putimagePng(WIDTH/9+20,HEIGHT/8 ,&im_support); //显示支撑点
		}
		else		//割右边绳子
		{
			isCutrope = 5;
			showlevel();  // 绘制
			putimagePng(x-50,y-45,&im_flash3);

			if(x<2.8*WIDTH/9+20 && x>2.8*WIDTH/9-70 && y<HEIGHT/8+48&& y>HEIGHT/8+30)
			{
				//显示绳子
				//putimagePng(2.8*WIDTH/9+12,HEIGHT/8+35,&im_rope_13);	
				//putimagePng(2.8*WIDTH/9+3,HEIGHT/8+52,&im_rope_13);
				putimagePng(2.8*WIDTH/9-6,HEIGHT/8+68,&im_rope_13);
				putimagePng(2.8*WIDTH/9-15,HEIGHT/8+83,&im_rope_13);
				putimagePng(2.8*WIDTH/9-24,HEIGHT/8+100,&im_rope_13);
				putimagePng(2.8*WIDTH/9-33,HEIGHT/8+116,&im_rope_13);
				putimagePng(2.8*WIDTH/9-42,HEIGHT/8+132,&im_rope_13);
				putimagePng(2.8*WIDTH/9-51,HEIGHT/8+147,&im_rope_13);
				putimagePng(2.8*WIDTH/9-60,HEIGHT/8+162,&im_rope_13);
				putimagePng(2.8*WIDTH/9-63,HEIGHT/8+165,&im_rope_13);

			}
			if(x<2.8*WIDTH/9+20 && x>2.8*WIDTH/9-70 && y<HEIGHT/8+65&& y>=HEIGHT/8+48)
			{		
				//显示绳子
				putimagePng(2.8*WIDTH/9+12,HEIGHT/8+35,&im_rope_13);	
				//putimagePng(2.8*WIDTH/9+3,HEIGHT/8+52,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-6,HEIGHT/8+68,&im_rope_13);
				putimagePng(2.8*WIDTH/9-15,HEIGHT/8+83,&im_rope_13);
				putimagePng(2.8*WIDTH/9-24,HEIGHT/8+100,&im_rope_13);
				putimagePng(2.8*WIDTH/9-33,HEIGHT/8+116,&im_rope_13);
				putimagePng(2.8*WIDTH/9-42,HEIGHT/8+132,&im_rope_13);
				putimagePng(2.8*WIDTH/9-51,HEIGHT/8+147,&im_rope_13);
				putimagePng(2.8*WIDTH/9-60,HEIGHT/8+162,&im_rope_13);
				putimagePng(2.8*WIDTH/9-63,HEIGHT/8+165,&im_rope_13);
			}

			if(x<2.8*WIDTH/9+20 && x>2.8*WIDTH/9-70 && y<HEIGHT/8+85&& y>=HEIGHT/8+65)
			{
				//显示绳子
				putimagePng(2.8*WIDTH/9+12,HEIGHT/8+35,&im_rope_13);	
				putimagePng(2.8*WIDTH/9+3,HEIGHT/8+52,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-6,HEIGHT/8+68,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-15,HEIGHT/8+83,&im_rope_13);
				putimagePng(2.8*WIDTH/9-24,HEIGHT/8+100,&im_rope_13);
				putimagePng(2.8*WIDTH/9-33,HEIGHT/8+116,&im_rope_13);
				putimagePng(2.8*WIDTH/9-42,HEIGHT/8+132,&im_rope_13);
				putimagePng(2.8*WIDTH/9-51,HEIGHT/8+147,&im_rope_13);
				putimagePng(2.8*WIDTH/9-60,HEIGHT/8+162,&im_rope_13);
				putimagePng(2.8*WIDTH/9-63,HEIGHT/8+165,&im_rope_13);
			}
			if(x<2.8*WIDTH/9+20 && x>2.8*WIDTH/9-70 && y<HEIGHT/8+100&& y>=HEIGHT/8+85)
			{
				//显示绳子
				putimagePng(2.8*WIDTH/9+12,HEIGHT/8+35,&im_rope_13);	
				putimagePng(2.8*WIDTH/9+3,HEIGHT/8+52,&im_rope_13);
				putimagePng(2.8*WIDTH/9-6,HEIGHT/8+68,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-15,HEIGHT/8+83,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-24,HEIGHT/8+100,&im_rope_13);
				putimagePng(2.8*WIDTH/9-33,HEIGHT/8+116,&im_rope_13);
				putimagePng(2.8*WIDTH/9-42,HEIGHT/8+132,&im_rope_13);
				putimagePng(2.8*WIDTH/9-51,HEIGHT/8+147,&im_rope_13);
				putimagePng(2.8*WIDTH/9-60,HEIGHT/8+162,&im_rope_13);
				putimagePng(2.8*WIDTH/9-63,HEIGHT/8+165,&im_rope_13);
			}
			if(x<2.8*WIDTH/9+20 && x>2.8*WIDTH/9-70 && y<HEIGHT/8+115&& y>=HEIGHT/8+100)
			{
				//显示绳子
				putimagePng(2.8*WIDTH/9+12,HEIGHT/8+35,&im_rope_13);	
				putimagePng(2.8*WIDTH/9+3,HEIGHT/8+52,&im_rope_13);
				putimagePng(2.8*WIDTH/9-6,HEIGHT/8+68,&im_rope_13);
				putimagePng(2.8*WIDTH/9-15,HEIGHT/8+83,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-24,HEIGHT/8+100,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-33,HEIGHT/8+116,&im_rope_13);
				putimagePng(2.8*WIDTH/9-42,HEIGHT/8+132,&im_rope_13);
				putimagePng(2.8*WIDTH/9-51,HEIGHT/8+147,&im_rope_13);
				putimagePng(2.8*WIDTH/9-60,HEIGHT/8+162,&im_rope_13);
				putimagePng(2.8*WIDTH/9-63,HEIGHT/8+165,&im_rope_13);
			}
			if(x<2.8*WIDTH/9+20 && x>2.8*WIDTH/9-70 && y<HEIGHT/8+130&& y>=HEIGHT/8+110)
			{
				//显示绳子
				putimagePng(2.8*WIDTH/9+12,HEIGHT/8+35,&im_rope_13);
				putimagePng(2.8*WIDTH/9+3,HEIGHT/8+52,&im_rope_13);
				putimagePng(2.8*WIDTH/9-6,HEIGHT/8+68,&im_rope_13);
				putimagePng(2.8*WIDTH/9-15,HEIGHT/8+83,&im_rope_13);
				putimagePng(2.8*WIDTH/9-24,HEIGHT/8+100,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-33,HEIGHT/8+116,&im_rope_13);
				//	putimagePng(2.8*WIDTH/9-42,HEIGHT/8+132,&im_rope_13);
				putimagePng(2.8*WIDTH/9-51,HEIGHT/8+147,&im_rope_13);
				putimagePng(2.8*WIDTH/9-60,HEIGHT/8+162,&im_rope_13);
				putimagePng(2.8*WIDTH/9-63,HEIGHT/8+165,&im_rope_13);
			}
			if(x<2.8*WIDTH/9+20 && x>2.8*WIDTH/9-70 && y<HEIGHT/8+145&& y>=HEIGHT/8+130)
			{
				//显示绳子

				putimagePng(2.8*WIDTH/9+12,HEIGHT/8+35,&im_rope_13);
				putimagePng(2.8*WIDTH/9+3,HEIGHT/8+52,&im_rope_13);
				putimagePng(2.8*WIDTH/9-6,HEIGHT/8+68,&im_rope_13);
				putimagePng(2.8*WIDTH/9-15,HEIGHT/8+83,&im_rope_13);
				putimagePng(2.8*WIDTH/9-24,HEIGHT/8+100,&im_rope_13);
				putimagePng(2.8*WIDTH/9-33,HEIGHT/8+116,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-42,HEIGHT/8+132,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-51,HEIGHT/8+147,&im_rope_13);
				putimagePng(2.8*WIDTH/9-60,HEIGHT/8+162,&im_rope_13);
				putimagePng(2.8*WIDTH/9-63,HEIGHT/8+165,&im_rope_13);
			}
			if(x<2.8*WIDTH/9+20 && x>2.8*WIDTH/9-70 && y<HEIGHT/8+170&& y>=HEIGHT/8+145)
			{
				//显示绳子
				putimagePng(2.8*WIDTH/9+12,HEIGHT/8+35,&im_rope_13);
				putimagePng(2.8*WIDTH/9+3,HEIGHT/8+52,&im_rope_13);
				putimagePng(2.8*WIDTH/9-6,HEIGHT/8+68,&im_rope_13);
				putimagePng(2.8*WIDTH/9-15,HEIGHT/8+83,&im_rope_13);
				putimagePng(2.8*WIDTH/9-24,HEIGHT/8+100,&im_rope_13);
				putimagePng(2.8*WIDTH/9-33,HEIGHT/8+116,&im_rope_13);
				putimagePng(2.8*WIDTH/9-42,HEIGHT/8+132,&im_rope_13);
				putimagePng(2.8*WIDTH/9-51,HEIGHT/8+147,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-60,HEIGHT/8+162,&im_rope_13);
				//putimagePng(2.8*WIDTH/9-63,HEIGHT/8+165,&im_rope_13);
			}

		}
		putimagePng(2.8*WIDTH/9-87,HEIGHT/8+186, &im_sweet); // 显示糖果
		FlushBatchDraw();
	}
};
Rope rope;

void MOUSE()//鼠标消息函数
{
	if(MouseHit())//有鼠标信息
	{
		m=GetMouseMsg();//获取鼠标信息
		if(m.uMsg==WM_LBUTTONDOWN)//如果鼠标点击
		{
			if(isCutrope == 0)		//第一关鼠标信息
			{
				rope.Cutropelevel1(m.x,m.y);
				Sleep(400);
			}
			if(isCutrope == 3)		//第二关鼠标信息
			{
				rope.Cutropelevel2(m.x,m.y);
				Sleep(400);
			}
			if(isSweet != 0)		//控制泡泡
			{
				sweet.touch(m.x,m.y);
			}
		}
	}
}

void update()
{
	BeginBatchDraw();//批量绘制
	MOUSE();
	FlushBatchDraw();
}

void gameover()
{
	EndBatchDraw();
	getch();
	closegraph();
}

int main()
{
	startup();  // 初始化
	while(1)  // 重复运行
	{
		showlevel();
		update();
	}
	gameover();     // 游戏结束、后续处理
	return 0;
}
